From db979c0dae5f380c2673dc91b65bb6c274362b25 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Sun, 20 Jul 2014 22:23:47 +0000 Subject: [PATCH] Make mtk_logger use the system tmp directory (/tmp or the one pointed by TMPDIR or $USERPROFILE%/AppData/Local/Temp or whatever) for the file it creates that holds the device's memory. --- gpsbabel/mtk_logger.cc | 26 +++++++++++++++++++++++--- gpsbabel/xmldoc/formats/mtk.xml | 5 ++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/gpsbabel/mtk_logger.cc b/gpsbabel/mtk_logger.cc index 1fdf6c02a..2d144cecc 100644 --- a/gpsbabel/mtk_logger.cc +++ b/gpsbabel/mtk_logger.cc @@ -56,6 +56,8 @@ #include #include +#include + #include "defs.h" #include "gbser.h" #include "gbfile.h" /* used for csv output */ @@ -230,9 +232,6 @@ static enum MTK_DEVICE_TYPE mtk_device = MTK_LOGGER; struct mtk_loginfo mtk_info; const char LIVE_CHAR[4] = {'-', '\\','|','/'}; -static const char TEMP_DATA_BIN[]= "data.bin"; -static const char TEMP_DATA_BIN_OLD[]= "data_old.bin"; - const char CMD_LOG_DISABLE[]= "$PMTK182,5*20\r\n"; const char CMD_LOG_ENABLE[] = "$PMTK182,4*21\r\n"; @@ -281,6 +280,27 @@ static void dbg(int l, const char* msg, ...) } va_end(ap); } + +// Returns a fully qualified pathname to a temporary file that is a copy +// of the data downloaded from the device. Only two copies are ever in play, +// the primary (e.g. "/tmp/data.bin") and the backup ("/tmp/data_old.bin"). +// +// It returns a temporary C string - it's totally kludged in to replace +// TEMP_DATA_BIN being string constants. +static const char* GetTempName(bool backup) { + const char kData[]= "data.bin"; + const char kDataBackup[]= "data_old.bin"; + + QString t = QDir::tempPath(); + t += QDir::separator(); + t += backup ? kDataBackup : kData; + // If your temp directory isn't representable in Latin1, you're going to + // have a bad day. + return t.toLatin1(); +} +#define TEMP_DATA_BIN GetTempName(false) +#define TEMP_DATA_BIN_OLD GetTempName(true) + static int do_send_cmd(const char* cmd, int cmdLen) { int rc; diff --git a/gpsbabel/xmldoc/formats/mtk.xml b/gpsbabel/xmldoc/formats/mtk.xml index 9276ca1f2..a665412c8 100644 --- a/gpsbabel/xmldoc/formats/mtk.xml +++ b/gpsbabel/xmldoc/formats/mtk.xml @@ -65,7 +65,10 @@ If you can confirm success with others, please share with us. frequently pair this with commodity USB/Serial converter internally. So these devices typically look like Prolific, FTDI, or Silab usb/serial devices to the host OS. You'll need drivers for that whatever chip - your product uses for your operating system. + your product uses for your operating system. For the "A+ GPS Recorder", + the Silicon Labs CP210x chip is used. On OS/X, you'll get + awesome device names like /dev/cu.usbmodem1d13410 - fortunately, our GUI + makes that multiple choice so you don't have to guess. Downloaded data will be stored in data.bin file in the current -- 2.30.2